DAY10:Is this a triangle?


Posted by birdbirdmurmur on 2023-07-23

題目連結:

Is this a triangle?

解法:

暴力解法

function isTriangle(a,b,c) {
if (a + b > c && a + c > b && b + c > a) {
  return true; 
}
  return false;
}

簡潔解法

function isTriangle(a,b,c){
   return a + b > c && a + c > b && c + b > a;
}

心得筆記:

這題很簡單
就是很基本的判斷三角形是否成立
值得學習的是使用更簡潔的回傳方式


#javascript #Codewars







Related Posts

圖型識別學習筆記:圖型識別介紹

圖型識別學習筆記:圖型識別介紹

初試啼聲,只用原生 JS 跟 CSS 寫「口罩地圖 」Ep.04

初試啼聲,只用原生 JS 跟 CSS 寫「口罩地圖 」Ep.04

[Release Notes] 20200924_v1 - Fix blog post serie checkbox bug & add publish type modal

[Release Notes] 20200924_v1 - Fix blog post serie checkbox bug & add publish type modal


Comments